package org.pada.domain.event;

import org.pada.client.exception.SystemException;

import static org.pada.client.exception.SystemErrorCode.DOMAIN_EVENT_ERR;

/**
 * @author pengshen
 * @date 2022.05.21 08:19
 */
public interface IEventHandler<T extends AbstractDomainEvent> {

    default void handle(T event) {
        try {
            doHandle(event);
        } catch (Exception e) {
            throw new SystemException(DOMAIN_EVENT_ERR, e);
        }
    }

    /**
     * event handler
     * @param event
     */
    void doHandle(T event);
}
